import axios from 'axios'

const request = axios.create({
    NODE_ENV: '"development"',//添加
    baseURL: 'http://localhost:8090/api',
    timeout: 20000
})

request.interceptors.request.use(config => {
    let token;
    try{
    token=sessionStorage.getItem('token')
    console.log('前端请求token',token)
    }catch(err){
        throw err
    }
    if(token!=null||token!=undefined){
        config.headers.Authorization=token 
        config.headers["Access-Control-Allow-Origin"]="http://127.0.0.1:8090";
    }
    return config
}, error => {
    console.log(error)
    Promise.reject(error)
})
request.interceptors.response.use(
    response => {
        return response.data
    },
    error => {
        return Promise.reject(error)
    }
)

export default request